package o;

import android.content.Context;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.gamebox.service.welfare.campaign.bean.CampaignCardItemBean;
import com.huawei.gamebox.service.welfare.campaign.card.BaseCampaignCard;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Locale;
import o.exp.d;

public class fbu extends BaseCampaignCard {
    private boolean ʻ = false;
    private Context ʼ;
    private View ʽ;
    private TextView ˋ;
    private TextView ˎ;
    private TextView ॱ;
    private TextView ॱॱ;
    private boolean ᐝ;

    public fbu(Context context, boolean z) {
        super(context);
        this.ʼ = context;
        ॱ("CampaignCard");
        this.ᐝ = z;
    }

    public void ॱ(boolean z) {
        this.ʻ = z;
    }

    public cgz ˏ(View view) {
        ˏ((ImageView) view.findViewById(d.ꞌ));
        this.ॱ = (TextView) view.findViewById(d.ˊ);
        this.ˎ = (TextView) view.findViewById(d.ˏ);
        this.ॱॱ = (TextView) view.findViewById(d.ˑॱ);
        this.ˋ = (TextView) view.findViewById(d.ˉॱ);
        this.ʽ = view.findViewById(d.ʽॱ);
        ʽ(view);
        view.setBackgroundResource(exp$e.ᐝ);
        return this;
    }

    public void ˏ(CardBean cardBean) {
        int i = 0;
        if (this.ʽॱ != null) {
            this.ʽॱ.setImageResource(exp$e.ॱॱ);
        }
        super.ˏ(cardBean);
        CampaignCardItemBean campaignCardItemBean = (CampaignCardItemBean) cardBean;
        String ᐝ = campaignCardItemBean.ᐝ();
        String ˋॱ = campaignCardItemBean.ˋॱ();
        String ˊ = campaignCardItemBean.ˊ();
        CharSequence ॱ = campaignCardItemBean.ॱ();
        if (TextUtils.isEmpty(ॱ)) {
            ॱ = "";
        }
        this.ॱ.setText(ॱ);
        ॱ = campaignCardItemBean.ॱˊ();
        if (TextUtils.isEmpty(ॱ)) {
            ॱ = "";
        }
        this.ˎ.setText(ॱ);
        long ˋ = ˋ(ᐝ);
        long ˋ2 = ˋ(ˋॱ);
        long ˋ3 = ˋ(ˊ);
        this.ॱ.setAlpha(1.0f);
        this.ˎ.setAlpha(1.0f);
        this.ॱॱ.setAlpha(1.0f);
        String ˋ4;
        if (ˋ3 < ˋ) {
            ˋ4 = ˋ(ˋ);
            this.ॱॱ.setText(this.ʼ.getResources().getString(exp$f.ॱˋ, new Object[]{ˋ4}));
        } else if (ˋ3 < ˋ2) {
            ˋ4 = ˋ(ˋ2);
            this.ॱॱ.setText(this.ʼ.getResources().getString(exp$f.ˋॱ, new Object[]{ˋ4}));
        } else {
            this.ॱॱ.setText(this.ʼ.getResources().getString(exp$f.ʻ));
            this.ॱ.setAlpha(0.3f);
            this.ˎ.setAlpha(0.3f);
            this.ॱॱ.setAlpha(0.3f);
        }
        if (this.ʽ != null) {
            if (this.ʻ) {
                int i2;
                View view = this.ʽ;
                if (this.ᐝ) {
                    i2 = 4;
                } else {
                    i2 = 0;
                }
                view.setVisibility(i2);
            } else {
                View view2 = this.ʽ;
                if (!ˊᐝ()) {
                    i = 4;
                }
                view2.setVisibility(i);
            }
        }
        long ͺ = campaignCardItemBean.ͺ();
        if (ͺ == 0) {
            ͺ = System.currentTimeMillis();
        }
        campaignCardItemBean.ˎ(ͺ);
        ˋ(this.ˋ, campaignCardItemBean.ˋʻ());
        ᐝ(this.ˎ);
    }

    private long ˋ(String str) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
        if (str == null) {
            return -1;
        }
        try {
            if (str.isEmpty()) {
                return -1;
            }
            return simpleDateFormat.parse(str).getTime();
        } catch (ParseException e) {
            Logger.e("CampaignCard", e.toString());
            return -1;
        }
    }

    private String ˋ(long j) {
        if (j != -1) {
            return DateUtils.formatDateTime(this.ʼ, j, 131092);
        }
        return "";
    }
}
